<template>
    <div v-if="showPage" style="width: 100%;height: 100%;position: relative;">
        <div
            style="width: 280px;height: 100%;display: inline-block;position: fixed;top: 0;left: 0;background-color: #fff;box-shadow: 0 4px 10px rgba(0,0,0,0.3);">
            <div
                style="width: 100%;height: 80px;display: flex;align-items: center;justify-content: center;flex-direction: column;gap: 10px;">
                <img style="height: 40px;" :src="images.logo" alt="">
            </div>
            <div style="width: 100%;height: calc(100% - 80px);overflow-x: hidden;overflow-y: auto;">
                <tree></tree>
            </div>
        </div>
        <div style="width: calc(100% - 280px);height: 100%;display: inline-block;position: fixed;top: 0;right: 0;">

        </div>
    </div>
</template>

<script setup>
import { ref, reactive, defineProps, computed, watch, onMounted, onBeforeUnmount } from 'vue'
import store from '../module/store'
import router from '@/router';
import images from '@/assets/images';
import tool from '@/module/tool';
import yButton from '@/components/yButton.vue';
import tree from '../components/tree.vue'

const leftTree = ref({
    data: [
        {
            title: '用户管理',
            path: 'userMgr',
            children: [
                {
                    title: '创建用户',
                    path: 'add'
                },
                {
                    title: '管理用户',
                    path: 'list'
                },
            ]
        }
    ]
})

const showPage = ref(false)

const homeData = ref(undefined)

onMounted(async () => {
    if (store.getItem('userData') == undefined) {
        router.push('/login')
        return
    }
    let re = await tool.requestMethod('/user/homeData', {
        account: store.getItem('userData').account
    })
    if (re.status == 1) {
        if (re.results.per.admin == false && re.results.per.sadmin == false) {
            tool.controlWarningForm(true, 'PC端仅限管理员和超级管理员登录', () => {
                location.reload()
            }, undefined, false)
            return
        }
        homeData.value = re.results
        showPage.value = true
        tool.controlCoverForm(false)
    } else {
        tool.controlWarningForm(true, re.content, () => {
            location.reload()
        }, undefined, false)
    }
})
</script>

<style scoped></style>